<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class m_ijin_model extends arfaModel {
    function __construct() {
        parent::__construct();
		$this->table_name	= "master_ijin";
		$this->primary_key	= "ID_IJIN";
		$this->order_by		= "ID_IJIN ASC";
    }

	function get_join_by2($id,$single=FALSE,$column=FALSE){ //Zulmi Adi Rizki 23 Juli 2013
		$this->db->join("dt_pertanyaan","master_ijin.ID_IJIN = dt_pertanyaan.ID_IJIN AND dt_pertanyaan.ID_PERTANYAAN = " . $id, "left");
		$this->db->where("STATUS",1);
		count($this->db->ar_orderby) || $this->db->order_by($this->order_by);
		$this->db->select($column == FALSE ? "*" : $column)->from($this->table_name);
		$single == FALSE || $this->db->limit(1);
		$method = $single ? 'row_array' : 'result_array';
		return $this->db->get()->$method();
	}

    public function get_key_jenis_izin ($key_field, $value_field, $ids = FALSE){

        // Get records
        // $this->db->select($key_field.', '.$value_field);
        // $this->db->select('*');
        $this->db->where('STATUS', '1');
        $result = $this->get($ids);

        // Turn results into key=>value pair array.
        $data = array();
        if (count($result) > 0) {

            if ($ids != FALSE && !is_array($ids)) {
                $result = array($result);
            }

            foreach ($result as $row) {
                $data[$row[$key_field]] = $row[$value_field];
            }
        }

        return $data;
    }
}